//
//  Tools.m
//  999-考勤定位
//
//  Created by 李晓东 on 2018/4/10.
//  Copyright © 2018年 PeanutXu. All rights reserved.
//

#import "Tools.h"

@implementation Tools

+ (NSInteger)transformInSeconds:(NSString *)time{
    
    NSArray *array = [time componentsSeparatedByString:@":"]; //从字符A中分隔成2个元素的数组
    NSString *HH = array[0];
    NSString *MM= array[1];
//    NSString *ss = array[2];
    NSInteger h = [HH integerValue];
    NSInteger m = [MM integerValue];
//    NSInteger s = [ss integerValue];
    NSInteger seconds = h*3600 + m*60;
    return seconds;
}

+ (NSString *)transformInDate: (NSInteger)seconds{
    NSInteger s = seconds % 60;
    NSInteger m = (seconds - s) / 60 % 60;
    NSInteger h = (seconds - s - m * 60) / 60 / 60 % 24;
    NSString *hourStr = [NSString stringWithFormat:@"%02ld:%02ld", h, m];
    return hourStr;
}
@end
